﻿using System;
using ANZ_AIM_BLL.Model;
using System.Data.OleDb;
using System.Data;

namespace ANZ_AIM_BLL.Utils
{
    class PopulateObjectHelper
    {
        public static User PopulateUserObject(OleDbDataReader reader)
        {
            User user = new User();
            user.UserID = reader["UserID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["UserID"]) : string.Empty;
            user.Password = reader["Password"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Password"]) : string.Empty;
            user.UserName = reader["Username"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Username"]) : string.Empty;
            user.FullName = reader["FullName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FullName"]) : string.Empty;
            user.Email = reader["Email"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Email"]) : string.Empty;
            user.Role = reader["Role"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Role"]) : string.Empty;
            user.IsActive = reader["IsActive"].GetType() != typeof(DBNull) ? Convert.ToBoolean(reader["IsActive"]) : true;
            user.CreatedBy = reader["CreatedBy"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CreatedBy"]) : string.Empty;
            user.CreatedDate = reader["CreatedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["CreatedDate"]) : (DateTime?)null;
            user.LastUpdatedBy = reader["LastUpdatedBy"].GetType() != typeof(DBNull) ? Convert.ToString(reader["LastUpdatedBy"]) : string.Empty;
            user.LastUpdatedDate = reader["LastUpdatedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["LastUpdatedDate"]) : (DateTime?)null;
            user.MustChangePwd = reader["MustChangePwd"].GetType() != typeof(DBNull) ? Convert.ToString(reader["MustChangePwd"]) : string.Empty;
            user.LastChangedPwd = reader["LastChangedPwd"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["LastChangedPwd"]) : (DateTime?)null;
            user.IsLock = reader["IsLock"].GetType() != typeof(DBNull) ? Convert.ToBoolean(reader["IsLock"]) : true;
            user.PwdArray = reader["PwdArray"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PwdArray"]) : string.Empty;
            user.LockDate = reader["LockDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["LockDate"]) : (DateTime?)null;

            return user;
        }

        public static Configuration PopulateConfigurationObject(OleDbDataReader reader)
        {
            Configuration config = new Configuration();
            config.ConfigID = reader["ConfigID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ConfigID"]) : string.Empty;
            config.ConfigValue = reader["ConfigValue"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ConfigValue"]) : string.Empty;
            config.Description = reader["Description"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Description"]) : string.Empty;

            return config;
        }

        public static MailConfig PopulateMailConfigObject(OleDbDataReader reader)
        {
            MailConfig mailConfig = new MailConfig();
            mailConfig.ID = reader["ID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ID"]) : string.Empty;
            mailConfig.Branch = reader["Branch"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Branch"]) : string.Empty;
            mailConfig.Floor = reader["Floor"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Floor"]) : string.Empty;
            mailConfig.CreatedDate = reader["CreatedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["CreatedDate"]) : (DateTime?)null;
            mailConfig.LastUpdate = reader["LastUpdate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["LastUpdate"]) : (DateTime?)null;

            return mailConfig;
        }

        //public static CandidateOffline PopulateCandidateOfflineObject(OleDbDataReader reader)
        //{
        //    CandidateOffline ca = new CandidateOffline();
        //    ca.PersonalCode = reader["PersonalCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PersonalCode"]) : string.Empty;
        //    ca.Channel = reader["Channel"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Channel"]) : string.Empty;
        //    ca.Team = reader["Team"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Team"]) : string.Empty;
        //    ca.FullName_E = reader["FullName_E"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FullName_E"]) : string.Empty;
        //    ca.FullName_V = reader["FullName_V"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FullName_V"]) : string.Empty;
        //    ca.CellPhone = reader["CellPhone"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CellPhone"]) : string.Empty;
        //    ca.DateOfBirth = reader["DateOfBirth"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["DateOfBirth"]) : (DateTime?)null;
        //    ca.College = reader["College"].GetType() != typeof(DBNull) ? Convert.ToString(reader["College"]) : string.Empty;
        //    ca.Qualification = reader["Qualification"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Qualification"]) : string.Empty;
        //    ca.IDNumber = reader["IDNumber"].GetType() != typeof(DBNull) ? Convert.ToString(reader["IDNumber"]) : string.Empty;
        //    ca.IssuedDate = reader["IssuedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["IssuedDate"]) : (DateTime?)null;
        //    ca.IssuedPlace = reader["IssuedPlace"].GetType() != typeof(DBNull) ? Convert.ToString(reader["IssuedPlace"]) : string.Empty;
        //    ca.PermanentAddress = reader["PermanentAddress"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PermanentAddress"]) : string.Empty;
        //    ca.Interviewer = reader["Interviewer"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Interviewer"]) : string.Empty;
        //    ca.InterviewDate = reader["InterviewDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["InterviewDate"]) : (DateTime?)null;
        //    ca.TrainingCallStatus = reader["TrainingCallStatus"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingCallStatus"]) : string.Empty;
        //    ca.TrainingCallStatusRemarks = reader["TrainingCallStatusRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingCallStatusRemarks"]) : string.Empty;
        //    ca.CICSanctionDeliveryDate = reader["CICSanctionDeliveryDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["CICSanctionDeliveryDate"]) : (DateTime?)null;
        //    ca.CICSanctionDelivererName = reader["CICSanctionDelivererName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CICSanctionDelivererName"]) : string.Empty;
        //    ca.CICResult = reader["CICResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CICResult"]) : string.Empty;
        //    ca.SanctionResult = reader["SanctionResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["SanctionResult"]) : string.Empty;
        //    ca.PECCheckResult = reader["PECCheckResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PECCheckResult"]) : string.Empty;
        //    ca.PECRemarks = reader["PECRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PECRemarks"]) : string.Empty;
        //    ca.TrainingBatch = reader["TrainingBatch"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingBatch"]) : string.Empty;
        //    ca.TrainingDate = reader["TrainingDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["TrainingDate"]) : (DateTime?)null;
        //    ca.TrainerName = reader["TrainerName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainerName"]) : string.Empty;
        //    ca.TrainingAttendance = reader["TrainingAttendance"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingAttendance"]) : string.Empty;
        //    ca.TrainingAttendanceRemarks = reader["TrainingAttendanceRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingAttendanceRemarks"]) : string.Empty;
        //    ca.ReTest = reader["ReTest"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ReTest"]) : string.Empty;
        //    ca.ReTestRequirement = reader["ReTestRequirement"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ReTestRequirement"]) : string.Empty;
        //    ca.TrainingResult = reader["TrainingResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingResult"]) : string.Empty;
        //    ca.OBEligible = reader["OBEligible"].GetType() != typeof(DBNull) ? Convert.ToString(reader["OBEligible"]) : string.Empty;
        //    ca.DocumentCompletion = reader["DocumentCompletion"].GetType() != typeof(DBNull) ? Convert.ToString(reader["DocumentCompletion"]) : string.Empty;
        //    ca.DocumentIncompletionRemarks = reader["DocumentIncompletionRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["DocumentIncompletionRemarks"]) : string.Empty;
        //    ca.PCReceiptSubmissionDate = reader["PCReceiptSubmissionDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["PCReceiptSubmissionDate"]) : (DateTime?)null;
        //    ca.PCReportSubmissionDate = reader["PCReportSubmissionDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["PCReportSubmissionDate"]) : (DateTime?)null;
        //    ca.HiringManagerName = reader["HiringManagerName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["HiringManagerName"]) : string.Empty;
        //    ca.HiringManagerAcknowledgeDate = reader["HiringManagerAcknowledgeDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["HiringManagerAcknowledgeDate"]) : (DateTime?)null;
        //    ca.DelegateApproverName = reader["DelegateApproverName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["DelegateApproverName"]) : string.Empty;
        //    ca.ApprovingDate = reader["ApprovingDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["ApprovingDate"]) : (DateTime?)null;
        //    ca.OnBoarding = reader["OnBoarding"].GetType() != typeof(DBNull) ? Convert.ToString(reader["OnBoarding"]) : string.Empty;
        //    ca.OnBoardingRemarks = reader["OnBoardingRemarks"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["OnBoardingRemarks"]) : (DateTime?)null;
        //    ca.CICSanctionRequestDate = reader["CICSanctionRequestDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["CICSanctionRequestDate"]) : (DateTime?)null;
        //    ca.TrainingResultCC = reader["TrainingResultCC"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingResultCC"]) : string.Empty;
        //    ca.CheckChannel = reader["CheckChannel"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CheckChannel"]) : string.Empty;
  
        //    return ca;
        //}

        //public static CandidateOffline PopulateCandidateOfflineObject(DataRow row)
        //{
        //    CandidateOffline ca = new CandidateOffline();
        //    ca.PersonalCode = row["PersonalCode"].GetType() != typeof(DBNull) ? Convert.ToString(row["PersonalCode"]) : string.Empty;
        //    ca.Channel = row["Channel"].GetType() != typeof(DBNull) ? Convert.ToString(row["Channel"]) : string.Empty;
        //    ca.FullName_E = row["FullName_E"].GetType() != typeof(DBNull) ? Convert.ToString(row["FullName_E"]) : string.Empty;
        //    ca.FullName_V = row["FullName_V"].GetType() != typeof(DBNull) ? Convert.ToString(row["FullName_V"]) : string.Empty;
        //    ca.CellPhone = row["CellPhone"].GetType() != typeof(DBNull) ? Convert.ToString(row["CellPhone"]) : string.Empty;
        //    ca.DateOfBirth = row["DateOfBirth"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["DateOfBirth"]) : (DateTime?)null;
        //    ca.College = row["College"].GetType() != typeof(DBNull) ? Convert.ToString(row["College"]) : string.Empty;
        //    ca.Qualification = row["Qualification"].GetType() != typeof(DBNull) ? Convert.ToString(row["Qualification"]) : string.Empty;
        //    ca.IDNumber = row["IDNumber"].GetType() != typeof(DBNull) ? Convert.ToString(row["IDNumber"]) : string.Empty;
        //    ca.IssuedDate = row["IssuedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["IssuedDate"]) : (DateTime?)null;
        //    ca.IssuedPlace = row["IssuedPlace"].GetType() != typeof(DBNull) ? Convert.ToString(row["IssuedPlace"]) : string.Empty;
        //    ca.PermanentAddress = row["PermanentAddress"].GetType() != typeof(DBNull) ? Convert.ToString(row["PermanentAddress"]) : string.Empty;
        //    ca.Interviewer = row["Interviewer"].GetType() != typeof(DBNull) ? Convert.ToString(row["Interviewer"]) : string.Empty;
        //    ca.InterviewDate = row["InterviewDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["InterviewDate"]) : (DateTime?)null;
        //    ca.TrainingCallStatus = row["TrainingCallStatus"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingCallStatus"]) : string.Empty;
        //    ca.TrainingCallStatusRemarks = row["TrainingCallStatusRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingCallStatusRemarks"]) : string.Empty;
        //    ca.CICSanctionDeliveryDate = row["CICSanctionDeliveryDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["CICSanctionDeliveryDate"]) : (DateTime?)null;
        //    ca.CICSanctionDelivererName = row["CICSanctionDelivererName"].GetType() != typeof(DBNull) ? Convert.ToString(row["CICSanctionDelivererName"]) : string.Empty;
        //    ca.CICResult = row["CICResult"].GetType() != typeof(DBNull) ? Convert.ToString(row["CICResult"]) : string.Empty;
        //    ca.SanctionResult = row["SanctionResult"].GetType() != typeof(DBNull) ? Convert.ToString(row["SanctionResult"]) : string.Empty;
        //    ca.PECCheckResult = row["PECCheckResult"].GetType() != typeof(DBNull) ? Convert.ToString(row["PECCheckResult"]) : string.Empty;
        //    ca.PECRemarks = row["PECRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(row["PECRemarks"]) : string.Empty;
        //    ca.TrainingBatch = row["TrainingBatch"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingBatch"]) : string.Empty;
        //    ca.TrainingDate = row["TrainingDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["TrainingDate"]) : (DateTime?)null;
        //    ca.TrainerName = row["TrainerName"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainerName"]) : string.Empty;
        //    ca.TrainingAttendance = row["TrainingAttendance"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingAttendance"]) : string.Empty;
        //    ca.TrainingAttendanceRemarks = row["TrainingAttendanceRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingAttendanceRemarks"]) : string.Empty;
        //    ca.ReTest = row["ReTest"].GetType() != typeof(DBNull) ? Convert.ToString(row["ReTest"]) : string.Empty;
        //    ca.ReTestRequirement = row["ReTestRequirement"].GetType() != typeof(DBNull) ? Convert.ToString(row["ReTestRequirement"]) : string.Empty;
        //    ca.TrainingResult = row["TrainingResult"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingResult"]) : string.Empty;
        //    ca.OBEligible = row["OBEligible"].GetType() != typeof(DBNull) ? Convert.ToString(row["OBEligible"]) : string.Empty;
        //    ca.DocumentCompletion = row["DocumentCompletion"].GetType() != typeof(DBNull) ? Convert.ToString(row["DocumentCompletion"]) : string.Empty;
        //    ca.DocumentIncompletionRemarks = row["DocumentIncompletionRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(row["DocumentIncompletionRemarks"]) : string.Empty;
        //    ca.PCReceiptSubmissionDate = row["PCReceiptSubmissionDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["PCReceiptSubmissionDate"]) : (DateTime?)null;
        //    ca.PCReportSubmissionDate = row["PCReportSubmissionDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["PCReportSubmissionDate"]) : (DateTime?)null;
        //    ca.HiringManagerName = row["HiringManagerName"].GetType() != typeof(DBNull) ? Convert.ToString(row["HiringManagerName"]) : string.Empty;
        //    ca.HiringManagerAcknowledgeDate = row["HiringManagerAcknowledgeDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["HiringManagerAcknowledgeDate"]) : (DateTime?)null;
        //    ca.DelegateApproverName = row["DelegateApproverName"].GetType() != typeof(DBNull) ? Convert.ToString(row["DelegateApproverName"]) : string.Empty;
        //    ca.ApprovingDate = row["ApprovingDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["ApprovingDate"]) : (DateTime?)null;
        //    ca.OnBoarding = row["OnBoarding"].GetType() != typeof(DBNull) ? Convert.ToString(row["OnBoarding"]) : string.Empty;
        //    ca.OnBoardingRemarks = row["OnBoardingRemarks"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["OnBoardingRemarks"]) : (DateTime?)null;
        //    ca.CICSanctionRequestDate = row["CICSanctionRequestDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(row["CICSanctionRequestDate"]) : (DateTime?)null;
        //    ca.TrainingResultCC = row["TrainingResultCC"].GetType() != typeof(DBNull) ? Convert.ToString(row["TrainingResultCC"]) : string.Empty;
        //    ca.CheckChannel = row["CheckChannel"].GetType() != typeof(DBNull) ? Convert.ToString(row["CheckChannel"]) : string.Empty;

        //    return ca;
        //}

        public static Candidate PopulateCandidateObject(OleDbDataReader reader)
        {
            Candidate ca = new Candidate();
            ca.CVCode = reader["CVCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CVCode"]) : string.Empty;
            ca.Channel = reader["Channel"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Channel"]) : string.Empty;
            ca.Team = reader["Team"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Team"]) : string.Empty;
            ca.FullName_E = reader["FullName_E"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FullName_E"]) : string.Empty;
            ca.FullName_V = reader["FullName_V"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FullName_V"]) : string.Empty;
            ca.CellPhone = reader["CellPhone"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CellPhone"]) : string.Empty;
            ca.DateOfBirth = reader["DateOfBirth"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["DateOfBirth"]) : (DateTime?)null;
            ca.College = reader["College"].GetType() != typeof(DBNull) ? Convert.ToString(reader["College"]) : string.Empty;
            ca.Qualification = reader["Qualification"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Qualification"]) : string.Empty;
            ca.IDNumber = reader["IDNumber"].GetType() != typeof(DBNull) ? Convert.ToString(reader["IDNumber"]) : string.Empty;
            ca.IssuedDate = reader["IssuedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["IssuedDate"]) : (DateTime?)null;
            ca.IssuedPlace = reader["IssuedPlace"].GetType() != typeof(DBNull) ? Convert.ToString(reader["IssuedPlace"]) : string.Empty;
            ca.PermanentAddress = reader["PermanentAddress"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PermanentAddress"]) : string.Empty;
            ca.Interviewer = reader["Interviewer"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Interviewer"]) : string.Empty;
            ca.InterviewDate = reader["InterviewDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["InterviewDate"]) : (DateTime?)null;
            ca.TrainingCallStatus = reader["TrainingCallStatus"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingCallStatus"]) : string.Empty;
            ca.TrainingCallStatusRemarks = reader["TrainingCallStatusRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingCallStatusRemarks"]) : string.Empty;
            ca.CICSanctionDeliveryDate = reader["CICSanctionDeliveryDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["CICSanctionDeliveryDate"]) : (DateTime?)null;
            ca.CICSanctionDelivererName = reader["CICSanctionDelivererName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CICSanctionDelivererName"]) : string.Empty;
            ca.CICResult = reader["CICResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CICResult"]) : string.Empty;
            ca.SanctionResult = reader["SanctionResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["SanctionResult"]) : string.Empty;
            ca.PECCheckResult = reader["PECCheckResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PECCheckResult"]) : string.Empty;
            ca.PECRemarks = reader["PECRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PECRemarks"]) : string.Empty;
            ca.TrainingBatch = reader["TrainingBatch"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingBatch"]) : string.Empty;
            ca.TrainingDate = reader["TrainingDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["TrainingDate"]) : (DateTime?)null;
            ca.TrainerName = reader["TrainerName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainerName"]) : string.Empty;
            ca.TrainingAttendance = reader["TrainingAttendance"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingAttendance"]) : string.Empty;
            ca.TrainingAttendanceRemarks = reader["TrainingAttendanceRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingAttendanceRemarks"]) : string.Empty;
            ca.ReTest = reader["ReTest"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ReTest"]) : string.Empty;
            ca.ReTestRequirement = reader["ReTestRequirement"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ReTestRequirement"]) : string.Empty;
            ca.TrainingResult = reader["TrainingResult"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingResult"]) : string.Empty;
            ca.OBEligible = reader["OBEligible"].GetType() != typeof(DBNull) ? Convert.ToString(reader["OBEligible"]) : string.Empty;
            ca.DocumentCompletion = reader["DocumentCompletion"].GetType() != typeof(DBNull) ? Convert.ToString(reader["DocumentCompletion"]) : string.Empty;
            ca.DocumentIncompletionRemarks = reader["DocumentIncompletionRemarks"].GetType() != typeof(DBNull) ? Convert.ToString(reader["DocumentIncompletionRemarks"]) : string.Empty;
            ca.PCReceiptSubmissionDate = reader["PCReceiptSubmissionDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["PCReceiptSubmissionDate"]) : (DateTime?)null;
            ca.PCReportSubmissionDate = reader["PCReportSubmissionDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["PCReportSubmissionDate"]) : (DateTime?)null;
            ca.HiringManagerName = reader["HiringManagerName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["HiringManagerName"]) : string.Empty;
            ca.HiringManagerAcknowledgeDate = reader["HiringManagerAcknowledgeDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["HiringManagerAcknowledgeDate"]) : (DateTime?)null;
            ca.DelegateApproverName = reader["DelegateApproverName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["DelegateApproverName"]) : string.Empty;
            ca.ApprovingDate = reader["ApprovingDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["ApprovingDate"]) : (DateTime?)null;
            ca.OnBoarding = reader["OnBoarding"].GetType() != typeof(DBNull) ? Convert.ToString(reader["OnBoarding"]) : string.Empty;
            ca.OnBoardingRemarks = reader["OnBoardingRemarks"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["OnBoardingRemarks"]) : (DateTime?)null;
            ca.CICSanctionRequestDate = reader["CICSanctionRequestDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["CICSanctionRequestDate"]) : (DateTime?)null;
            ca.TrainingResultCC = reader["TrainingResultCC"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TrainingResultCC"]) : string.Empty;
            ca.CheckChannel = reader["CheckChannel"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CheckChannel"]) : string.Empty;
            ca.BatchFileID = reader["BatchFileID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BatchFileID"]) : string.Empty;
            
            ca.Role = reader["Role"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Role"]) : string.Empty;
            ca.Level = reader["Level"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Level"]) : string.Empty;
            ca.Category = reader["Category"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Category"]) : string.Empty;
            ca.ProductCategory = reader["ProductCategory"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ProductCategory"]) : string.Empty;
            ca.Product = reader["Product"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Product"]) : string.Empty;
            ca.TeamLeaderCode = reader["TeamLeaderCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TeamLeaderCode"]) : string.Empty;
            ca.JoiningDate = reader["JoiningDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["JoiningDate"]) : (DateTime?)null;
            ca.PromotionTransferDate = reader["PromotionTransferDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["PromotionTransferDate"]) : (DateTime?)null;
            ca.Status = reader["Status"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Status"]) : string.Empty;

            ca.FingerID = reader["FingerID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FingerID"]) : string.Empty;
            ca.PersonalTaxCode = reader["PersonalTaxCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PersonalTaxCode"]) : string.Empty;
            ca.ContractType = reader["ContractType"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ContractType"]) : string.Empty;
            ca.ContractTerm = reader["ContractTerm"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ContractTerm"]) : string.Empty;
            ca.ContractorName = reader["ContractorName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ContractorName"]) : string.Empty;
            ca.ContractSignDate = reader["ContractSignDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["ContractSignDate"]) : (DateTime?)null;
            ca.ContractExpiryDate = reader["ContractExpiryDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["ContractExpiryDate"]) : (DateTime?)null;
            ca.BankAccount = reader["BankAccount"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BankAccount"]) : string.Empty;
            ca.BankBranchAddress = reader["BankBranchAddress"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BankBranchAddress"]) : string.Empty;
            ca.BankName = reader["BankName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BankName"]) : string.Empty;
            ca.FillingRefCode = reader["FillingRefCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FillingRefCode"]) : string.Empty;
            ca.ProfressiveTarget = reader["ProfressiveTarget"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ProfressiveTarget"]) : string.Empty;

            return ca;
        }

        public static SaleInfo PopulateSaleInfoObject(OleDbDataReader reader)
        {
            SaleInfo saleInfo = new SaleInfo();
            saleInfo.ID = reader["ID"].GetType() != typeof(DBNull) ? int.Parse(reader["ID"].ToString()) : 0;
            saleInfo.ProfileID = reader["ProfileID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ProfileID"]) : string.Empty;
            saleInfo.SaleCode = reader["SaleCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["SaleCode"]) : string.Empty;
            saleInfo.CVCode = reader["CVCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["CVCode"]) : string.Empty;

            saleInfo.EmployeeFullName = reader["EmployeeFullName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["EmployeeFullName"]) : string.Empty;
            saleInfo.EmployeeFullNameE = reader["EmployeeFullNameE"].GetType() != typeof(DBNull) ? Convert.ToString(reader["EmployeeFullNameE"]) : string.Empty;
            saleInfo.Role = reader["Role"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Role"]) : string.Empty;
            saleInfo.Level = reader["Level"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Level"]) : string.Empty;
            saleInfo.Category = reader["Category"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Category"]) : string.Empty;
            saleInfo.ProductCategory = reader["ProductCategory"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ProductCategory"]) : string.Empty;
            saleInfo.Product = reader["Product"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Product"]) : string.Empty;
            saleInfo.TeamName = reader["TeamName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TeamName"]) : string.Empty;
            saleInfo.TeamLeaderCode = reader["TeamLeaderCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["TeamLeaderCode"]) : string.Empty;
            saleInfo.Channel = reader["Channel"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Channel"]) : string.Empty;
            saleInfo.JoiningDate = reader["JoiningDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["JoiningDate"]) : (DateTime?)null;
            saleInfo.PromotionTransferDate = reader["PromotionTransferDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["PromotionTransferDate"]) : (DateTime?)null;
            saleInfo.Status = reader["Status"].GetType() != typeof(DBNull) ? Convert.ToString(reader["Status"]) : string.Empty;

            saleInfo.IDCardNumber = reader["IDCardNumber"].GetType() != typeof(DBNull) ? Convert.ToString(reader["IDCardNumber"]) : string.Empty;
            saleInfo.DateOfBirth = reader["DateOfBirth"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["DateOfBirth"]) : (DateTime?)null;
            saleInfo.IDIssuedDate = reader["IDIssuedDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["IDIssuedDate"]) : (DateTime?)null;
            saleInfo.IDIssuedPlace = reader["IDIssuedPlace"].GetType() != typeof(DBNull) ? Convert.ToString(reader["IDIssuedPlace"]) : string.Empty;
            saleInfo.PermanentAddress = reader["PermanentAddress"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PermanentAddress"]) : string.Empty;
            saleInfo.MobilePhone = reader["MobilePhone"].GetType() != typeof(DBNull) ? Convert.ToString(reader["MobilePhone"]) : string.Empty;
            saleInfo.FingerID = reader["FingerID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FingerID"]) : string.Empty;
            saleInfo.PersonalTaxCode = reader["PersonalTaxCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["PersonalTaxCode"]) : string.Empty;


            saleInfo.ContractType = reader["ContractType"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ContractType"]) : string.Empty;
            saleInfo.ContractTerm = reader["ContractTerm"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ContractTerm"]) : string.Empty;
            saleInfo.ContractorName = reader["ContractorName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ContractorName"]) : string.Empty;
            saleInfo.ContractSignDate = reader["ContractSignDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["ContractSignDate"]) : (DateTime?)null;
            saleInfo.ContractExpiryDate = reader["ContractExpiryDate"].GetType() != typeof(DBNull) ? Convert.ToDateTime(reader["ContractExpiryDate"]) : (DateTime?)null;

            saleInfo.BankAccount = reader["BankAccount"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BankAccount"]) : string.Empty;
            saleInfo.BankBranchAddress = reader["BankBranchAddress"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BankBranchAddress"]) : string.Empty;
            saleInfo.BankName = reader["BankName"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BankName"]) : string.Empty;
            
            saleInfo.FillingRefCode = reader["FillingRefCode"].GetType() != typeof(DBNull) ? Convert.ToString(reader["FillingRefCode"]) : string.Empty;
            saleInfo.ProfressiveTarget = reader["ProfressiveTarget"].GetType() != typeof(DBNull) ? Convert.ToString(reader["ProfressiveTarget"]) : string.Empty;
         
            saleInfo.BatchFileID = reader["BatchFileID"].GetType() != typeof(DBNull) ? Convert.ToString(reader["BatchFileID"]) : string.Empty;

            return saleInfo;
        }
    }
}
